from django.contrib import admin
from repositories.models import Repository

from jobs.models import Job

def Repository_scan(modeladmin, request, queryset):
  for object in queryset:
    j = Job.objects.create_job(object, 'scan')
    j.schedule()
    j.save()
Repository_scan.short_description = "Scan selected repositories"

class RepositoryAdmin(admin.ModelAdmin):
    actions = [Repository_scan]

admin.site.register(Repository, RepositoryAdmin)
